//
//  KZVocabularyImproveNetApi.m
//  听说弱点强化训练
//
//  Created by 朱凯 on 2018/8/23.
//  Copyright © 2018年 盛超. All rights reserved.
//

#import "KZVocabularyImproveNetApi.h"

@implementation KZVocabularyImproveNetApi

- (void)getUnfamiliarVocabularyPackage:(void(^)(KZVocabularyPackageModel *model))success
                               failuer:(void(^)(NSString *error))failure {
    
    self.requestUrl = @"api/ZXYYTS/W_ZXYYTS_GetUnfamiliarVocabularyPackage";
    
    [self requestGetMethodWithSuccess:^(id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        
        KZVocabularyPackageModel *model = [KZVocabularyPackageModel yy_modelWithDictionary:dict];
        success(model);
        NSLog(@"%@", dict);
        NSLog(@"kz_Net_Data:%@", dict);

        
    } Failure:^(NSError *error) {
        NSLog(@"kz_Net_Error:%@", error.localizedDescription);
        failure(error.localizedDescription);
    }];
}
// 保存生词词汇包
- (void)saveUnfamiliarVocabularyTrainRecord:(void(^)(void))success
                                    failuer:(void(^)(NSString *error))failure {
    
    self.requestUrl = @"api/ZXYYTS/W_ZXYYTS_SaveUnfamiliarVocabularyTrainRecord";
    
    [self requestPostMethodWithSuccess:^(id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        
        NSLog(@"kz_Net_Data:%@", dict);
        success();
    } Failure:^(NSError *error) {
        NSLog(@"kz_Net_Error:%@", error.localizedDescription);
        failure(error.localizedDescription);
    }];
}


// 获取我的生词本
- (void)getVocabularyBuilder:(void(^)(NSArray *))success
                     failuer:(void(^)(NSString *error))failure {
    
    self.requestUrl = @"api/ZXYYTS/W_ZXYYTS_GetVocabularyBuilder";
    
    [self requestGetMethodWithSuccess:^(id responseObject) {
        
        NSArray *list = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        NSMutableArray *temp = [NSMutableArray new];
        for (int i = 0; i < list.count; i ++) {
            KZVocabularyCurrentPackageDetailModel *model = [KZVocabularyCurrentPackageDetailModel yy_modelWithDictionary:list[i]];
            [temp addObject:model];
        }
        
        success(temp.copy);
        NSLog(@"kz_Net_Data:%@", list);
    } Failure:^(NSError *error) {
        NSLog(@"kz_Net_Error:%@", error.localizedDescription);
        failure(error.localizedDescription);
    }];
}
// 获取听说词汇包
- (void)getListenSayVocabularyPackageInfo:(void(^)(KZVocabularyPackageModel *model))success
                                  failuer:(void(^)(NSString *error))failure {
    
    self.requestUrl = @"api/ZXYYTS/W_ZXYYTS_GetListenSayVocabularyPackageInfo";
    
    [self requestGetMethodWithSuccess:^(id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        
        KZVocabularyPackageModel *model = [KZVocabularyPackageModel yy_modelWithDictionary:dict];
        success(model);
        NSLog(@"%@", dict);
        NSLog(@"kz_Net_Data:%@", dict);
    } Failure:^(NSError *error) {
        NSLog(@"kz_Net_Error:%@", error.localizedDescription);
        failure(error.localizedDescription);
    }];
}
// 保存听说词汇包记录
- (void)saveListenSayVocabularyTrainRecord:(void(^)(void))success
                                   failuer:(void(^)(NSString *error))failure {
    
    self.requestUrl = @"api/ZXYYTS/W_ZXYYTS_SaveListenSayVocabularyTrainRecord";
    
    [self requestPostMethodWithSuccess:^(id responseObject) {
        
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        
        NSLog(@"kz_Net_Data:%@", dict);
        success();
    } Failure:^(NSError *error) {
        NSLog(@"kz_Net_Error:%@", error.localizedDescription);
        failure(error.localizedDescription);
    }];
    
}
@end
